Skip to content

Add Viva.com driver - #34

Merged
elbanbydev merged 1 commit into
mainfrom
feature/gateway-viva
Dec 4, 2026
Merged

elbanbydev merged 1 commit into
mainfrom
feature/gateway-viva

Conversation

@elbanbydev

Copy link
Copy Markdown
Owner

What this adds

Tahseel::gateway('viva') - a Greek acquirer with a wide European footprint, on Smart Checkout.

  • createPayment() - OAuth2 client-credentials token from the accounts host (grant_type=client_credentials, client id/secret as Basic), then POST /checkout/v2/orders on the API host with minor-unit amounts and the 4-digit payment source. The 16-digit order code is kept a string (Viva's docs are explicit: a JS number cannot hold it) and becomes the documented https://www.vivapayments.com/web/checkout?ref={OrderCode} url.
  • verifyAndParseWebhook() - Viva-Signature-256 is the hex HMAC-SHA-256 of the raw body under the webhook secret, Viva-Signature the SHA-1 equivalent; the driver prefers the 256 header, falls back to the 1 one, compares in constant time, and refuses a body whose raw bytes it cannot see. Only the documented events are read (1796 payment created, 1797 reversal, 1798 payment failed, 4865 order updated), and the event and the transaction's own StatusId have to agree - a notification claiming success for a failed transaction is refused, not believed.
  • Status set honoured: F paid, A/C pending, R refunded, E/X failed, anything else refused. Amounts arrive in minor units with the currency as an ISO numeric code (978 = EUR), mapped before Money.

Honesty notes

  • No refunds: Viva documents them on a separate product surface I have not grounded, so the driver does not claim them. README, Arabic README, CHANGELOG and "What is not supported yet" all say so.
  • No transaction re-read: Viva's docs say to confirm with OrderCode plus TransactionId, StatusId and Amount, which the driver checks, and that is what it relies on.
  • Fixture-tested only, no live Viva account has run it.

Metadata

README (EN) + docs/ar/README.md in sync (count 23 → 24, driver table, full ## Viva.com section), CHANGELOG [Unreleased], composer.json description + keywords (viva, vivawallet, smart checkout), config block + VIVA_* env vars, every optional extra off by default.

Tests

13 fixture tests. Suite 622 passed / 1477 assertions, PHPStan level 8 clean, Pint clean.

Viva.com is a Greek acquirer with a wide European footprint, on Smart
Checkout:

- createPayment() takes an OAuth2 client-credentials token from the
  accounts host, creates the payment order and returns the documented
  ?ref={OrderCode} checkout url, keeping the 16-digit order code a string.
- Webhooks are signed over the raw body: Viva-Signature-256 is the hex
  HMAC-SHA-256 under the webhook secret, Viva-Signature the SHA-1 one.
- Only the documented events are read, the event and the transaction's own
  StatusId have to agree, and F is the only status treated as money.
- Refunds are not wrapped: Viva documents them on a separate surface.
@elbanbydev
elbanbydev merged commit 1f61ffc into main Dec 4, 2026
8 checks passed
@elbanbydev
elbanbydev deleted the feature/gateway-viva branch December 4, 2026 03:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants